package com.cn.wanxi.servlet.back.product;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.model.UserTypeModel;
import com.cn.wanxi.service.IUserTypeService;
import com.cn.wanxi.service.impl.UserTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/back/product/usertype")
public class UserTypeServlet extends HttpServlet {

    IUserTypeService userTypeService = new UserTypeServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //产品用户类型列表
        resp.setContentType("application/json");
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        List<UserTypeModel> userTypeList = userTypeService.getUserTypeList();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("userType",userTypeList);
        resp.getWriter().print(jsonObject);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
